package lib.register;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import jdbc.JdbcPort;

public class registerDao {
	public boolean insert(String uname,String uid,String ustatus,String pswd) throws SQLException {
        //注册驱动    使用驱动连接数据库
        Connection conn = null;
        PreparedStatement stmt = null;
        boolean res=false;
        try {
        	conn=JdbcPort.getConnection();
            String sql = "insert into libuser(uname,uid,ustatus,pswd) values(?,?,?,?)";
            stmt = conn.prepareStatement(sql);
            stmt.setString(1, uname);
            stmt.setString(2, uid);
            stmt.setString(3, ustatus); 
            stmt.setString(4, pswd);
            int result =stmt.executeUpdate();// 返回值代表收到影响的行数
            if(result>0) {
            	System.out.println("注册成功");
            	res=true;
            }
            else {
            	System.out.println("注册失败");
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return res;
    }
	
}
